<?php
class AdminWebUser extends CWebUser {
	protected function afterLogin($fromCookie)
	{
		$uid = $this->getId();
		$user = AdminMember::model()->findByPk($uid);
		if(empty($user)) $this->logout();
		$user->last_login_time=time();
		$user->save();
		$attributes['uid']=$uid;
		$attributes['username']=$user->username;
		$attributes['role_id']=$user->role_id;
		$attributes['email']=$user->email;
		$attributes['last_login_time']=$user->last_login_time;
		$attributes['isactive']=$user->isactive;
		$this->setState('userinfo',$attributes);
		AdminLog::add('登录系统',$uid);
	}
	public function get_auth_power(){
		$auth = array();
		$userinfo = Yii::app()->user->getState('userinfo');
		if(empty($userinfo['role_id'])) return $auth;
		$roles = explode(',', $userinfo['role_id']);
		foreach ($roles as $v){
			$role_auth = AdminRole::get_role_auth_cache($v);
			$auth = $auth+$role_auth;
		}
		return $auth;
	}
}
?>